<template>
  <div>
    <h1>用户管理</h1>
    <el-table :data="list" stripe style="width: 100%">
      <el-table-column prop="id" label="id"> </el-table-column>
      <el-table-column prop="username" label="用户名"> </el-table-column>
      <el-table-column prop="email" label="邮箱"> </el-table-column>
      <el-table-column prop="phone" label="电话"> </el-table-column>
      <el-table-column prop="createTime" label="注册时间">
        <template slot-scope="scope">
          {{ scope.row.createTime | filterTime }}
        </template>
      </el-table-column>
    </el-table>
    <myPagination :total="total" @pageChange="change" />
  </div>
</template>

<script>
import { userlist } from "@/utils/api";
import myPagination from "@/components/pagination";
export default {
  name: "",
  components: {
    myPagination
  },
  data() {
    return {
      list: [],
      pageNum:1,
      total: 1
    };
  },
  filters: {
    filterTime(a) {
      var date = new Date(a).toLocaleString();
      return date;
    }
  },
  mounted() {
    userlist(this.pageNum).then(res => {
      this.list = res.data.data.list;
      this.total = res.data.data.total;
    });
  },
  methods: {
    change(val) {
      userlist(val).then(res => {
        this.list = res.data.data.list;
      });
    },
    goDetails(val){
      this.$router.push({path:'/detail',query:{val:val}})
    }

  }
};
</script>

<style lang="scss" scoped></style>
